// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.world.logger;

import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import zombie.world.ItemInfo;

public class Log {
    public abstract static class BaseItemLog extends Log.BaseLog {
        protected final ItemInfo itemInfo;

        public BaseItemLog(ItemInfo _itemInfo) {
            this.itemInfo = _itemInfo;
        }

        @Override
        abstract void saveAsText(FileWriter var1, String var2) throws IOException;

        protected String getItemString() {
            return "fulltype = \""
                + this.itemInfo.getFullType()
                + "\", registeryID = "
                + this.itemInfo.getRegistryID()
                + ", existsVanilla = "
                + this.itemInfo.isExistsAsVanilla()
                + ", isModded = "
                + this.itemInfo.isModded()
                + ", modID = \""
                + this.itemInfo.getModID()
                + "\", obsolete = "
                + this.itemInfo.isObsolete()
                + ", removed = "
                + this.itemInfo.isRemoved()
                + ", isLoaded = "
                + this.itemInfo.isLoaded();
        }
    }

    public abstract static class BaseLog {
        protected boolean ignoreSaveCheck = false;

        public boolean isIgnoreSaveCheck() {
            return this.ignoreSaveCheck;
        }

        abstract void saveAsText(FileWriter var1, String var2) throws IOException;
    }

    public static class Comment extends Log.BaseLog {
        protected String txt;

        public Comment(String _txt) {
            this.ignoreSaveCheck = true;
            this.txt = _txt;
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "-- " + this.txt + System.lineSeparator());
        }
    }

    public static class Info extends Log.BaseLog {
        protected final List<String> mods;
        protected final String timeStamp;
        protected final String saveWorld;
        protected final int worldVersion;
        public boolean HasErrored = false;

        public Info(String _timeStamp, String _saveWorld, int _worldVersion, List<String> _mods) {
            this.ignoreSaveCheck = true;
            this.timeStamp = _timeStamp;
            this.saveWorld = _saveWorld;
            this.worldVersion = _worldVersion;
            this.mods = _mods;
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{" + System.lineSeparator());
            w.write(padding + "\ttype = \"info\"," + System.lineSeparator());
            w.write(padding + "\ttimeStamp = \"" + this.timeStamp + "\"," + System.lineSeparator());
            w.write(padding + "\tsaveWorld = \"" + this.saveWorld + "\"," + System.lineSeparator());
            w.write(padding + "\tworldVersion = " + this.worldVersion + "," + System.lineSeparator());
            w.write(padding + "\thasErrored = " + this.HasErrored + "," + System.lineSeparator());
            w.write(padding + "\titemMods = {" + System.lineSeparator());

            for (int _int = 0; _int < this.mods.size(); _int++) {
                w.write(padding + "\t\t\"" + (String)this.mods.get(_int) + "\"," + System.lineSeparator());
            }

            w.write(padding + "\t}," + System.lineSeparator());
            w.write(padding + "}," + System.lineSeparator());
        }
    }

    public static class ModIDChangedItem extends Log.BaseItemLog {
        protected final String oldModID;
        protected final String newModID;

        public ModIDChangedItem(ItemInfo itemInfo, String oldModId, String newModId) {
            super(itemInfo);
            this.oldModID = oldModId;
            this.newModID = newModId;
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{ type = \"modchange_item\", oldModID = \"" + this.oldModID + "\", " + this.getItemString() + " }" + System.lineSeparator());
        }
    }

    public static class ObsoleteItem extends Log.BaseItemLog {
        public ObsoleteItem(ItemInfo itemInfo) {
            super(itemInfo);
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{ type = \"obsolete_item\", " + this.getItemString() + " }" + System.lineSeparator());
        }
    }

    public static class RegisterItem extends Log.BaseItemLog {
        public RegisterItem(ItemInfo itemInfo) {
            super(itemInfo);
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{ type = \"reg_item\", " + this.getItemString() + " }" + System.lineSeparator());
        }
    }

    public static class RegisterObject extends Log.BaseLog {
        protected final String objectName;
        protected final int ID;

        public RegisterObject(String _objectName, int id) {
            this.objectName = _objectName;
            this.ID = id;
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{ type = \"reg_obj\", id = " + this.ID + ", obj = \"" + this.objectName + "\" }" + System.lineSeparator());
        }
    }

    public static class ReinstateItem extends Log.BaseItemLog {
        public ReinstateItem(ItemInfo itemInfo) {
            super(itemInfo);
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(padding + "{ type = \"reinstate_item\", " + this.getItemString() + " }" + System.lineSeparator());
        }
    }

    public static class RemovedItem extends Log.BaseItemLog {
        protected final boolean isScriptMissing;

        public RemovedItem(ItemInfo itemInfo, boolean _isScriptMissing) {
            super(itemInfo);
            this.isScriptMissing = _isScriptMissing;
        }

        @Override
        public void saveAsText(FileWriter w, String padding) throws IOException {
            w.write(
                padding + "{ type = \"removed_item\", scriptMissing = " + this.isScriptMissing + ", " + this.getItemString() + " }" + System.lineSeparator()
            );
        }
    }
}
